﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Shop.Core.Domain.Common;

namespace Shop.Core.Domain.Catalog
{
    /// <summary>
    /// 商品模版
    /// </summary>
    public class ProductTemplate : BaseEntity<string>
    {
        private IList<ProductCategory> _productCategories;
        private Manufacturer manufacturer;
        private IList<ProductPicture> productPictures;
        private IList<SpecificationAttributeSet> productSpecificationAttributes;

        //public override string Id
        //{
        //    get
        //    {
        //        return base.Id;
        //    }
        //    set
        //    {
        //        base.Id = value;
        //    }
        //}

        /// <summary>
        /// Gets or sets the name
        /// </summary>
        public virtual string Name
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the short description
        /// </summary>
        public virtual string ShortDescription
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the full description
        /// </summary>
        public virtual string FullDescription
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the description
        /// </summary>
        public virtual string Description
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the Global Trade Item Number (GTIN). These identifiers include UPC (in North America), EAN (in Europe), JAN (in Japan), and ISBN (for books).
        /// </summary>
        public virtual string Gtin
        {
            get;
            set;
        }

        /// <summary>
        /// 是否需要配送，点卡、虚拟商品无需配送
        /// </summary>
        public virtual bool IsShipEnabled
        {
            get;
            set;
        }

        /// <summary>
        /// 是否免运费
        /// </summary>
        public virtual bool IsFreeShipping
        {
            get;
            set;
        }

        /// <summary>
        /// 库存
        /// </summary>
        public virtual int StockQuantity
        {
            get;
            set;
        }

        /// <summary>
        /// 是否显示库存
        /// </summary>
        public virtual bool DisplayStockQuantity
        {
            get;
            set;
        }

        /// <summary>
        /// 销售价
        /// </summary>
        public virtual Money Price
        {
            get;
            set;
        }

        /// <summary>
        /// 市场价
        /// </summary>
        public virtual Money ListPrice
        {
            get;
            set;
        }

        /// <summary>
        /// 成本价
        /// </summary>
        public virtual Money CostPrise
        {
            get;
            set;
        }

        /// <summary>
        /// 重量
        public virtual Mass Weight
        {
            get;
            set;
        }

        /// <summary>
        /// 长
        /// </summary>
        public virtual Lenght Length
        {
            get;
            set;
        }

        /// <summary>
        /// 宽
        /// </summary>
        public virtual Lenght Width
        {
            get;
            set;
        }

        /// <summary>
        /// 高
        /// </summary>
        public virtual Lenght Height
        {
            get;
            set;
        }

        /// <summary>
        /// 上架开始时间
        /// </summary>
        public virtual DateTime? AvailableStartDateTime
        {
            get;
            set;
        }

        /// <summary>
        /// 下架结束时间
        /// </summary>
        public virtual DateTime? AvailableEndDateTime
        {
            get;
            set;
        }

        /// <summary>
        /// 库存管理方式
        /// </summary>
        public virtual ManageInventoryMethod ManageInventoryMethod
        {
            get;
            set;
        }

        /// <summary>
        /// 制造商模版Id。
        /// </summary>
        /// <remarks>
        /// 与之对应的有模版表。
        /// </remarks>
        /// <see cref="Shop.Core.Domain.Catalog.ViewTemplate, Shop.Core"/>
        public virtual int TemplateId
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets a value indicating whether the entity is published
        /// </summary>
        public virtual bool Published
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets a value indicating whether the entity has been deleted
        /// </summary>
        public virtual bool Deleted
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the date and time of product creation
        /// </summary>
        public virtual DateTime CreatedOn
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the date and time of product update
        /// </summary>
        public virtual DateTime ModifiedOn
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the collection of ProductCategory
        /// </summary>
        public virtual IList<ProductCategory> ProductCategories
        {
            get
            {
                return _productCategories ?? (_productCategories = new List<ProductCategory>());
            }
            protected set
            {
                _productCategories = value;
            }
        }

        /// <summary>
        /// Gets or sets the collection of ProductManufacturer
        /// </summary>
        public virtual Manufacturer Manufacturer
        {
            get
            {
                return this.manufacturer ?? (this.manufacturer = new Manufacturer());
            }
            set
            {
                this.manufacturer = value;
            }
        }

        /// <summary>
        /// 商品图片集合
        /// </summary>
        public virtual IList<ProductPicture> ProductPictures
        {
            get
            {
                return productPictures ?? (productPictures = new List<ProductPicture>());
            }
            protected set
            {
                productPictures = value;
            }
        }

        /// <summary>
        /// 商品属性
        /// </summary>
        public virtual IList<SpecificationAttributeSet> ProductSpecificationAttributes
        {
            get
            {
                return productSpecificationAttributes ?? (productSpecificationAttributes = new List<SpecificationAttributeSet>());
            }
            protected set
            {
                productSpecificationAttributes = value;
            }
        }

        #region TODO

        //private ICollection<ProductVariant> _productVariants;
        //private ICollection<ProductReview> _productReviews;
        //private ICollection<ProductTag> _productTags;

        /// <summary>
        /// Gets or sets the backorder mode
        /// </summary>
        //public virtual BackorderMode BackorderMode
        //{
        //    get;
        //    set;
        //}

        /// <summary>
        /// 零库存后，浏览产品的行为
        /// </summary>
        //public virtual LowStockActivity LowStockActivity
        //{
        //    get;
        //    set;
        //}
        /// <summary>
        /// Gets or sets the rating sum (approved reviews)
        /// </summary>
        //public virtual int ApprovedRatingSum
        //{
        //    get;
        //    set;
        //}

        /// <summary>
        /// Gets or sets the rating sum (not approved reviews)
        /// </summary>
        //public virtual int NotApprovedRatingSum
        //{
        //    get;
        //    set;
        //}

        /// <summary>
        /// Gets or sets the total rating votes (approved reviews)
        /// </summary>
        //public virtual int ApprovedTotalReviews
        //{
        //    get;
        //    set;
        //}

        /// <summary>
        /// Gets or sets the total rating votes (not approved reviews)
        /// </summary>
        //public virtual int NotApprovedTotalReviews
        //{
        //    get;
        //    set;
        //}

        /// <summary>
        /// Gets or sets the product specification attribute
        /// </summary>
        //public virtual ICollection<ProductTag> ProductTags
        //{
        //    get
        //    {
        //        return _productTags ?? (_productTags = new List<ProductTag>());
        //    }
        //    protected set
        //    {
        //        _productTags = value;
        //    }
        //}

        //public ICollection<ProductReview> _productReviews;
        ///// <summary>
        ///// Gets or sets the collection of product reviews
        ///// </summary>
        //public virtual ICollection<ProductReview> ProductReviews
        //{
        //    get
        //    {
        //        return _productReviews ?? (_productReviews = new List<ProductReview>());
        //    }
        //    protected set
        //    {
        //        _productReviews = value;
        //    }
        //}

        ///// <summary>
        ///// Gets or sets the additional shipping charge
        ///// </summary>
        //public virtual decimal AdditionalShippingCharge
        //{
        //    get;
        //    set;
        //}
        #endregion
    }
}
